package com.gitee.huanminabc.dynamicdb.config;

import com.gitee.huanminabc.dynamicdb.interceptor.DBTenantInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @program: java-huanmin-utils
 * @description: 拦截器配置
 * @author: huanmin
 * @create: 2024-12-09 15:05
 **/
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {
    /*
     * 拦截器依赖于Spring容器，此处拦截了所有，需要对静态资源进行放行
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 拦截器默认的执行顺序，就是它的注册顺序，也可以通过Order手动设置控制，值越小越先执行。
        registry.addInterceptor(new DBTenantInterceptor()).addPathPatterns("/**").order(Integer.MIN_VALUE);
    }
}
